<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/22 0022
 * Time: 16:40
 */
namespace app\api\model;
use think\Db;

class Bank
{
    private $tableName = 'bank';
    private $config = '';
    public function __construct($id=null)
    {
        if($id){
            $this->config = Db::view('bank',true)
                ->view('classes','class_name','classes.id=bank.classes_id','left')
                ->view('branch','branch_name','branch.id=bank.branch_id','left')
                ->view('three_level','three_level_name','three_level.id=bank.three_level_id','left')
                ->view('situation','situation_name','situation.id=bank.classes_id','left')
                ->where('bank.id',$id)
                ->find();
        }
    }

    /**获取id的题目
     * @param null $id
     * @return array|bool|\PDOStatement|string|\think\Collection
     */
    public function get($id=null){
        if(!$id&&!$this->config){
            return false;
        }
        if($id){
            $this->config = Db::view('bank',true)
                ->view('classes','class_name','classes.id=bank.classes_id','left')
                ->view('branch','branch_name','branch.id=bank.branch_id','left')
                ->view('three_level','three_level_name','three_level.id=bank.three_level_id','left')
                ->view('situation','situation_name','situation.id=bank.classes_id','left')
                ->where('bank.id',$id)
                ->find();
        }
        return $this->config;
    }
}